import { Component, OnInit, ViewChild, TemplateRef } from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { STColumn, STComponent, STData } from '@delon/abc';
import { SPage, ColumnType } from '@shared/components/table-page/table-page.component';
import { ACLService } from '@delon/acl';
import { ServePersonAddComponent } from '../serve-person-add/serve-person-add.component';
import { NzModalService } from 'ng-zorro-antd';

@Component({
  selector: 'app-watch-person-list-person-list',
  templateUrl: './person-list.component.html',
})
export class PersonListComponent implements OnInit {
  @ViewChild('st', { static: false }) st: STComponent;
  addFlag:boolean = this.aclService.canAbility("watch-person-list/add");//检查用户按钮权限
  editFlag:boolean =  this.aclService.canAbility("watch-person-list/edit");
  delFlag:boolean =  this.aclService.canAbility("watch-person-list/delete");
  watchFlag:boolean =  this.aclService.canAbility("watch-person-list/record");
  config: SPage = {
    columns: [
      {
        index: 'infoName',
        title: '用户名',
        width:100,
        filter: {
          placeholder: '请输入用户名称',
          type: 'string'
        }
      },
      {
        index: 'personType',
        title: '人员类型',
        width:100,
      },
      {
        index: 'infoMobile',
        title: '联系电话',
        width:120,
        filter: {
          placeholder: '请输入手机号',
          type: 'string'
        }
      },
      {
        index:'areaName',
        title:'区域名称',
        width:450,
        //className:'w200',
        filter:{
          placeholder: '请输入区域名称',
          type: 'string'
        }
      },
      {
        index: '',
        title: '操作',
        width:300,
        fixed:'right',
        buttons:[
          {
            text:'卡管理',
            click:(_record)=>{
              // this.carManage(_record);
            }
          }
        ]
      },
    ],
    showCheckBox: true,
    reqUrl:'/core/person/page',
  }
  constructor(private http: _HttpClient, private modal: NzModalService,private aclService: ACLService) { }

  ngOnInit() { }

  // 选择数据
  selectChange(e) {
    console.log(e);
    
  }
  addServePerson():void{
    const modal = this.modal.create({
      nzTitle: '新增人员',
      nzContent: ServePersonAddComponent,
      nzWidth: '60%',
      nzComponentParams: {
      },
      nzOnOk: () => {
        this.st.reload();
      },
      nzFooter: null
    })
    modal.afterClose.subscribe(res => {
      if (res === 'ok') {
        this.st.reload();
      }
    })
  }

}
